<template>
  <div class="home">
    <div class="home-header">
      <div>临停缴费</div>
      <div>
        <el-breadcrumb separator-class="el-icon-arrow-right">
          <el-breadcrumb-item>停车场管理</el-breadcrumb-item>
          <el-breadcrumb-item>缴费管理</el-breadcrumb-item>
          <el-breadcrumb-item>临停缴费</el-breadcrumb-item>
        </el-breadcrumb>
      </div>
    </div>

    <!-- 搜索区 重置区-->
    <div class="header">
      <el-input clearable v-model="orderNum" placeholder="订单编号"></el-input>
      <el-input clearable v-model="carNum" placeholder="车牌号码"></el-input>
      <el-select clearable v-model="payMethod" placeholder="支付方式">
        <el-option
          :key="v.id"
          v-for="v in payMethodAll"
          :label="v.payMethod"
          :value="v.payMethod"
        ></el-option>
      </el-select>
      <el-date-picker clearable
        v-model="value1"
        type="datetimerange"
        range-separator="—"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
      >
      </el-date-picker>
      <el-button
        type="success"
        class="el-icon-search"
        size="medium"
        @click="search"
        >查询</el-button
      >
      <el-button class="el-icon-refresh" size="medium" @click="reset"
        >重置</el-button
      >
      <!-- //测试时间查询 -->
      <!-- <button @click="btn">点击</button> -->
    </div>

    <!-- 数据 -->
    <div style="width: auto; background: #fff">
      <div
        style="
          display: flex;
          justify-content: space-between;
          padding: 10px 0 10px 0;
        "
      >
        <p style="font-size: 15px; font-weight: bold; margin: 5px 0 0 20px">
          查询结果列表
        </p>
      </div>
      <el-table :data="tableData" border style="width: 100%">
        <el-table-column prop="id" label="序号" width="100" align="center">
        </el-table-column>
        <el-table-column prop="orderNum" label="订单编号" align="center">
        </el-table-column>
        <el-table-column prop="carNum" label="车牌号码" align="center">
        </el-table-column>
        <el-table-column prop="payMoney" label="支付金额" align="center">
        </el-table-column>
        <el-table-column prop="payMethod" label="支付方式" align="center">
        </el-table-column>
        <el-table-column prop="payResult" label="支付结果" align="center">
        </el-table-column>
        <el-table-column
          prop="enterTime"
          label="进场时间"
          align="center"
          width="180"
        >
          <template slot-scope="scope">
            <span>{{ timeTrans(scope.row.enterTime) }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="address"
          label="所在位置"
          align="center"
          width="180"
        >
        </el-table-column>
        <el-table-column prop="parkingRegion" label="停车区域" align="center">
        </el-table-column>
        <el-table-column prop="parkingDuration" label="停车时长" align="center">
        </el-table-column>
        <el-table-column
          prop="payTime"
          label="缴费时间"
          align="center"
          width="180"
        >
          <template slot-scope="scope">
            <span>{{ timeTrans(scope.row.payTime) }}</span>
          </template>
        </el-table-column>

        <el-table-column label="操作" width="200" align="center">
          <template slot-scope="scope">
            <el-button
              @click="set(scope.row.id), (ownerDialog = true)"
              style="color: #0bb197"
              type="text"
              size="small"
              >详情</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </div>

    <!-- 分页 -->
    <div class="block">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage4"
        :page-sizes="[5, 10, 15, 20]"
        :page-size="count"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
        :background="true"
        class="msg-pagination-container"
      >
      </el-pagination>
    </div>

    <!-- 详情信息弹窗 -->
    <div class="regionSet">
      <el-dialog
        title="详情信息"
        :visible.sync="ownerDialog"
        class="regionSet-el-dialog"
      >
        <!-- <div>数据检测中---{{details.enterTime}}</div> -->
        <div class="regionSet-header">
          <div class="regionSetBtn">
            <div class="details-box">
              <div class="details" style="margin-right: 150px">
                <div>订单编号：</div>
                <div>{{ details.orderNum }}</div>
              </div>
              <div class="details">
                <div>车牌号码：</div>
                <div>{{ details.carNum }}</div>
              </div>
            </div>
            <div class="details-box">
              <div class="details" style="margin-right: 150px">
                <div>支付金额：</div>
                <div>{{ details.payMoney }}</div>
              </div>
              <div class="details">
                <div>支付方式：</div>
                <div>{{ details.payMethod }}</div>
              </div>
            </div>
            <div class="details-box">
              <div class="details" style="margin-right: 150px">
                <div>支付结果：</div>
                <div>{{ details.payResult }}</div>
              </div>
              <div class="details">
                <div>进场时间：</div>
                <div>{{ details.enterTime }}</div>
              </div>
            </div>
            <div class="details-box">
              <div class="details" style="margin-right: 150px">
                <div>所在位置：</div>
                <div>{{ details.address }}</div>
              </div>
              <div class="details">
                <div>停车区域：</div>
                <div>{{ details.parkingRegion }}</div>
              </div>
            </div>
            <div class="details-box">
              <div class="details" style="margin-right: 150px">
                <div>停车时长：</div>
                <div>{{ details.parkingDuration }}</div>
              </div>
              <div class="details">
                <div>缴费时间：</div>
                <div>{{ details.payTime }}</div>
              </div>
            </div>
          </div>
        </div>
      </el-dialog>
    </div>
  </div>
</template>

<script>
//时间戳函数引用
import time from "../utils/time";
export default {
  mixins: [time],
  data: function () {
    return {
      page: 1,
      count: 5,
      total: 1,
      id: "",
      orderNum: "",
      carNum: "",
      payMethod: "",
      currentPage4: 1,
      ownerDialog: false,
      value1: [],
      tableData: [
        {
          id: "1",
          orderNum: "1",
          carNum: "1",
          payMoney: "1",
          payMethod: "1",
          payResult: "1",
          enterTime: "1",
          address: "1",
          parkingRegion: "1",
          parkingDuration: "1",
          payTime: "1",
        },
      ],
      details: {},
      payMethodAll: [],
    };
  },
  methods: {
    //测试时间查询
    // btn: function () {
    //   console.log(this.value1[0].getTime());
    //   console.log(this.value1[1].getTime());
    // },
    //详情弹框
    set: function (index) {
      console.log(index);
      this.$axios({
        url: "/smart/temporary-pay/queryById/" + index,
        method: "GET",
      }).then(({ data }) => {
        console.log(data);
        if (data) {
          // this.$message.success("查询成功");
          data.enterTime = this.timeTrans(data.enterTime);
          data.payTime = this.timeTrans(data.payTime);
          this.details = data;
          // console.log("检测数据", this.details.enterTime);
        } else {
          this.$message.error("查看失败");
        }
      });
    },
    //改变条数
    handleSizeChange(val) {
      this.count = val;
      this.getData();
      // console.log(`每页 ${val} 条`);
    },
    //翻页
    handleCurrentChange(val) {
      this.page = val;
      this.getData();
      // console.log(`当前页: ${val}`);
    },
    getData: function () {
      if(this.value1 ==null){
        this.value1 = [];
      }
      this.$axios({
        url: "/smart/temporary-pay/queryByCondition",
        method: "POST",
        data: {
          pageNum: this.page,
          pageSize: this.count,
          orderNum:this.orderNum,
          carNum:this.carNum,
          payMethod:this.payMethod,
          startTime: this.value1[0],
          endTime: this.value1[1],
        },
      }).then(({ data }) => {
        console.log(data);
        if (data.code == "00000") {
          this.tableData = data.data.list;
          this.total = data.data.total;
        } else {
          this.$message.error("数据加载失败！");
        }
      });
    },
    search: function () {
      this.getData();
    },
    reset: function () {
      this.orderNum = "";
      this.carNum = "";
      this.payMethod = "";
      this.value1 = [];
      this.getData();
    },
  },
  mounted: function () {
    this.getData();
    this.$axios({
      url: "/smart/temporary-pay/queryByCondition",
      method: "POST",
      data: {
        pageNum: 1,
        pageSize: 10000,
      },
    }).then(({ data }) => {
      console.log("所有支付方式", data);
      if (data.code == "00000") {
        this.payMethodAll = data.data.list;
        console.log("挂载后测试", this.parkingAll);
      } else {
        this.$message.error("数据加载失败！");
      }
    });
  },
};
</script>

<style lang="less" scoped>
.home {
  height: 95%;
  margin: 20px 20px 0 20px;
}
.home-header {
  margin: 10px 0 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.header {
  width: 100%;
  height: 80px;
  background: #fff;
  display: flex;
  align-items: center;
  margin: 30px 0 20px 0;
}
.el-icon-search {
  background: #0bb197;
  margin-left: 10px;
}
.el-icon-refresh {
  background-color: white;
  color: #c0c4cc;
  border: 1px solid #c0c4cc;
}
.el-icon-refresh:hover {
  color: #0bb197;
}
.el-pagination {
  margin-top: 30px;
  text-align: right;
}
.el-input,
.el-select {
  width: 200px;
  margin: 10px;
}
.el-dialog {
  width: 60%;
}
.regionSet-header {
  width: 100%;
  height: 350px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.regionSetBtn {
  width: 100%;
  height: 95%;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  .details-box {
    display: flex;
    .details {
      width: 50%;
      display: flex;
      justify-content: space-between;
    }
  }
}
</style>
<style lang="less">
.msg-pagination-container.is-background .el-pager li:not(.disabled).active {
  /*当前选中页数的样式进行修改*/
  background-color: #0bb197;
  color: #fff;
}

// 详情信息弹窗

.regionSet .el-dialog__header {
  background: #0bb197;
  padding: 10px 20px 10px;
}
.regionSet .el-dialog__title {
  font-size: 15px;
  font-weight: bold;
  color: white;
}
.regionSet .el-dialog__headerbtn .el-dialog__close {
  color: #fff;
}
.regionSet .el-dialog__body {
  padding: 0px 20px;
}
</style>
